package com.gewu.bookeeping.MyDb.dao;

import android.content.Context;

import com.gewu.bookeeping.IModel.IMenyInDaoModel;
import com.gewu.bookeeping.MyDb.MyDatabase;
import com.gewu.bookeeping.MyDb.bean.ALIBeanIn;
import com.gewu.bookeeping.MyDb.bean.MesBeanIn;
import com.j256.ormlite.dao.Dao;

import java.sql.SQLException;
import java.util.List;

public class MesInPerson implements IMenyInDaoModel {

    private Dao<MesBeanIn,Integer> mesBeanIns;

    public MesInPerson(Context context) {
        try {
            this.mesBeanIns = MyDatabase.getInstance(context).getDao(MesBeanIn.class);
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }


    @Override
    public int add(Object m) {
        try {
           mesBeanIns.createIfNotExists((MesBeanIn) m);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public int delect(int id) {
        try {
            mesBeanIns.deleteById(id);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return 0;
    }

    @Override
    public List<MesBeanIn> quer() {
        List<MesBeanIn> time=null;
        try {
            time = mesBeanIns.queryForAll();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return time;
    }

    @Override
    public List<MesBeanIn> querLike(String values) {
        List<MesBeanIn> time=null;
        try {
            time = mesBeanIns.queryForEq("time", values);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return time;
    }
}
